package com.sais.manage.boot.building.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sais.manage.boot.building.dto.BuildingDTO;
import com.sais.manage.boot.building.dto.BuildingSearchDTO;
import com.sais.manage.boot.building.entity.Building;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 宿舍管理系统-宿舍楼 mapper 接口
 *
 * @author zwp
 * @date 2020/1/30
 **/
@Mapper
public interface BuildingMapper extends BaseMapper<Building> {

    /**
     * 添加宿舍楼信息
     *
     * @param building
     * @return
     */
    boolean createBuilding(@Param("building") Building building);

    /**
     * 根据 宿舍楼id 删除
     *
     * @param buildingId
     * @return
     */
    boolean deleteBuilding(@Param("buildingId") String buildingId);

    /**
     * 根据 宿舍楼id 查询信息
     *
     * @param buildingId
     * @return
     */
    BuildingDTO selectBuilding(@Param("buildingId") String buildingId);

    /**
     * 分页 条件查询 宿舍楼信息
     *
     * @param page
     * @param buildingSearchDTO
     * @return
     */
    Page<BuildingDTO> listBuilding(@Param("page") Page<BuildingDTO> page, @Param("buildingSearchDTO") BuildingSearchDTO buildingSearchDTO);

    /**
     * 宿舍楼 分配管理人员
     *
     * @param buildingId
     * @param userIds
     * @return
     */
    boolean bindBuildingUser(@Param("buildingId") String buildingId, @Param("userIds") List<String> userIds);

    /**
     * 根据 宿舍楼id 用户id 删除 宿舍楼得管理员
     *
     * @param buildingId
     * @param userIds
     * @return
     */
    boolean unbindBuildingUser(@Param("buildingId") String buildingId, @Param("userIds") List<String> userIds);

    /**
     * 根据房间id 查询 宿舍楼类型 即几人间
     *
     * @param roomId
     * @return
     */
    Integer selectBuildingTypeByRoomId(@Param("roomId") String roomId);

    /**
     * 根據 性別 查詢宿舍樓 列表
     *
     * @param gender
     * @return
     */
    List<String> listBuildingType(@Param("gender") Integer gender);

    /**
     * 查询当前用户管理的宿舍楼信息
     *
     * @param userId
     * @return
     */
    BuildingDTO selectBuildingByCurrentUserId(@Param("userId") String userId);

    BuildingDTO selectBuildingByRoomId(@Param("roomId") String roomId);

    /**
     * 根据用户id查询 其管理宿舍楼数量
     * @param userId
     * @return
     */
    Integer selectCountByBuilding(@Param("userId") String userId);
}
